package com.xiaoluo.lottery.exception;

/**
 * Created by Administrator on 2016/4/5.
 */
public class LotteryException extends RuntimeException{
    private Object[] params;
    private String error;
    public LotteryException(String error) {
        this.error=error;
    }
    public LotteryException(String error,Object[] params) {
        this(error);
        this.params=params;
        if(params!=null){
            for(int i=0;i<params.length;i++){
                error=error.replaceFirst("#"+(i+1),String.valueOf(params[i]));
            }
        }
    }
    public String getError() {
        return error;
    }

    @Override
    public  Throwable fillInStackTrace() {
        return this;
    }

    public static LotteryException build(String message){
        return new LotteryException(message);
    }
}
